<!DOCTYPE html>
<html>

	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<meta id="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" name="viewport">
		<meta name="apple-themes-web-app-capable" content="yes">
		<meta content="yes" name="apple-mobile-web-app-capable">
		<meta content="black" name="apple-mobile-web-app-status-bar-style">
		<meta content="telephone=no" name="format-detection">
		<meta content="email=no" name="format-detection">
		<meta name="format-detection" content="telephone=no">
		<title>个人资料</title>	
		<link rel="stylesheet" href="${s.base}/mobile/css/main.css" type="text/css" media="all">
	</head>

	<body>

		<header id="header">
			<div class="header_con">
				<a href="${s.base}/phone/address?memberId=${memberId}"><span></span></a>
                <div class="top_tit">
					<#if address??>
							修改地址
						<#else>
							添加地址
					</#if>
					</div>
			</div>
		</header>
		<input type="hidden" value="${address.id}" id="id"/>
		<input type="hidden" value="${memberId}" id="memberId"/>
		<div id="content_div">
             <div class="pay_02">
              <p class="border_bottom">姓名<span><input type="text" id="name"  value="${address.name}" style="width: 100%;height: 0.8rem;line-height: 0.8rem;border: 0px; text-align: right;" placeholder="请输入姓名" /></span></p>
             </div>
			<div class="pay_02">
				<p class="border_bottom">手机号<span><input type="text" id="phone" value="${address.phone}" style="width: 100%;height: 0.8rem;line-height: 0.8rem;border: 0px; text-align: right;" placeholder="请输入手机号" /></span></p>
			</div>
			<div class="pay_02">
				<p class="border_bottom">省<span><input type="text" id="province" value="${address.province}" style="width: 100%;height: 0.8rem;line-height: 0.8rem;border: 0px; text-align: right;" placeholder="请输入省" /></span></p>
			</div>
			<div class="pay_02">
				<p class="border_bottom">市<span><input type="text" id="city" value="${address.city}" style="width: 100%;height: 0.8rem;line-height: 0.8rem;border: 0px; text-align: right;" placeholder="请输入市" /></span></p>
			</div>
			<div class="pay_02">
				<p class="border_bottom">区<span><input type="text" id="area" value="${address.area}" style="width: 100%;height: 0.8rem;line-height: 0.8rem;border: 0px; text-align: right;" placeholder="请输入区" /></span></p>
			</div>
			<div class="pay_02">
				<p class="border_bottom">详细地址<span><input type="text" id="descripts" value="${address.descripts}" style="width: 100%;height: 0.8rem;line-height: 0.8rem;border: 0px; text-align: right;" placeholder="请输入详细地址" /></span></p>
			</div>
			<div class="pay_02">
				<p class="border_bottom">默认地址<span>
					<select style="width: 100%;height: 0.8rem;line-height: 0.8rem;border: 0px; text-align: right;" id="type" >
						<option <#if address.type=='2'>selected</#if> value="2">否</option>
						<option <#if address.type=='1'>selected</#if> value="1">是</option>
					</select>
				</span></p>
			</div>
              <div class="pay_04 margin_top_1"><a class="ui-btn" onclick="saveOrUpdate()">
				  <#if address??>
					  立即修改
					  <#else>
						  立即添加
				  </#if>
			  </a></div>
	
        
      </div>	
            <!--底部-->
			<!--底部结束-->
		   
           	<script src="${s.base}/mobile/js/jquery-1.7.2.min.js"></script>
		  <script type="text/javascript" src="${s.base}/mobile/js/common.js"></script>
		<script type="text/javascript" src="${s.base}/js/layer/layer.js"></script>
		<script type="text/javascript" src="${s.base}/js/base/commont.js"></script>
		<script type="text/javascript">
            /**
             * 添加
             */
            function saveOrUpdate() {
                var memberId=$("#memberId").val();
                var id=$("#id").val();
                var name=$("#name").val();
                var phone=$("#phone").val();
                var province=$("#province").val();
                var city=$("#city").val();
                var area=$("#area").val();
                var type=$("#type").val();
                var descripts=$("#descripts").val();

                if (name == null || ""==name){
                    layer.alert("请输入姓名");
                    return false;
                }
                if (phone == null || ""==phone){
                    layer.alert("请输入手机号");
                    return false;
                }
                if (province == null || ""==province){
                    layer.alert("请输入省");
                    return false;
                }
                if (city == null || ""==city){
                    layer.alert("请输入市");
                    return false;
                }
                if (area == null || ""==area){
                    layer.alert("请输入区");
                    return false;
                }
                if (descripts == null || ""==descripts){
                    layer.alert("请输入详细地址");
                    return false;
                }
                var t="添加成功";
                if(id!=null&&id!=""){
                    t="修改成功";
				}
                $.ajax({
                    type: "POST",
                    url: "/phone/address/updateOrAddEntity",
                    data: {"memberId":memberId,"id":id,"name":name,"phone":phone,"province":province,"city":city,"area":area,"descripts":descripts,"type":type},
                    success: function(result){
                        if(1==result.returnInfo.state){
                            showLayerAlertNoRefre(t);
                        }else{
                            showLayerAlertNoRefre(result.returnInfo.errorMsg);
                        }
                    },
                    error: function(result){
                        showLayerAlertNoRefre(result);
                    }
                });
            }

		</script>

	</body>

</html>